// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <ConnCompReduceAttributes.h>
#include <DataNode.h>

// ****************************************************************************
// Method: ConnCompReduceAttributes::ConnCompReduceAttributes
//
// Purpose:
//   Init utility for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

void ConnCompReduceAttributes::Init()
{
    target = 0.1;

    ConnCompReduceAttributes::SelectAll();
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::ConnCompReduceAttributes
//
// Purpose:
//   Copy utility for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

void ConnCompReduceAttributes::Copy(const ConnCompReduceAttributes &obj)
{
    target = obj.target;

    ConnCompReduceAttributes::SelectAll();
}

// Type map format string
const char *ConnCompReduceAttributes::TypeMapFormatString = CONNCOMPREDUCEATTRIBUTES_TMFS;
const AttributeGroup::private_tmfs_t ConnCompReduceAttributes::TmfsStruct = {CONNCOMPREDUCEATTRIBUTES_TMFS};


// ****************************************************************************
// Method: ConnCompReduceAttributes::ConnCompReduceAttributes
//
// Purpose:
//   Default constructor for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

ConnCompReduceAttributes::ConnCompReduceAttributes() :
    AttributeSubject(ConnCompReduceAttributes::TypeMapFormatString)
{
    ConnCompReduceAttributes::Init();
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::ConnCompReduceAttributes
//
// Purpose:
//   Constructor for the derived classes of ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

ConnCompReduceAttributes::ConnCompReduceAttributes(private_tmfs_t tmfs) :
    AttributeSubject(tmfs.tmfs)
{
    ConnCompReduceAttributes::Init();
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::ConnCompReduceAttributes
//
// Purpose:
//   Copy constructor for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

ConnCompReduceAttributes::ConnCompReduceAttributes(const ConnCompReduceAttributes &obj) :
    AttributeSubject(ConnCompReduceAttributes::TypeMapFormatString)
{
    ConnCompReduceAttributes::Copy(obj);
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::ConnCompReduceAttributes
//
// Purpose:
//   Copy constructor for derived classes of the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

ConnCompReduceAttributes::ConnCompReduceAttributes(const ConnCompReduceAttributes &obj, private_tmfs_t tmfs) :
    AttributeSubject(tmfs.tmfs)
{
    ConnCompReduceAttributes::Copy(obj);
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::~ConnCompReduceAttributes
//
// Purpose:
//   Destructor for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

ConnCompReduceAttributes::~ConnCompReduceAttributes()
{
    // nothing here
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::operator =
//
// Purpose:
//   Assignment operator for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

ConnCompReduceAttributes&
ConnCompReduceAttributes::operator = (const ConnCompReduceAttributes &obj)
{
    if (this == &obj) return *this;

    ConnCompReduceAttributes::Copy(obj);

    return *this;
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::operator ==
//
// Purpose:
//   Comparison operator == for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

bool
ConnCompReduceAttributes::operator == (const ConnCompReduceAttributes &obj) const
{
    // Create the return value
    return ((target == obj.target));
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::operator !=
//
// Purpose:
//   Comparison operator != for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

bool
ConnCompReduceAttributes::operator != (const ConnCompReduceAttributes &obj) const
{
    return !(this->operator == (obj));
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::TypeName
//
// Purpose:
//   Type name method for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

const std::string
ConnCompReduceAttributes::TypeName() const
{
    return "ConnCompReduceAttributes";
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::CopyAttributes
//
// Purpose:
//   CopyAttributes method for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

bool
ConnCompReduceAttributes::CopyAttributes(const AttributeGroup *atts)
{
    if(TypeName() != atts->TypeName())
        return false;

    // Call assignment operator.
    const ConnCompReduceAttributes *tmp = (const ConnCompReduceAttributes *)atts;
    *this = *tmp;

    return true;
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::CreateCompatible
//
// Purpose:
//   CreateCompatible method for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

AttributeSubject *
ConnCompReduceAttributes::CreateCompatible(const std::string &tname) const
{
    AttributeSubject *retval = 0;
    if(TypeName() == tname)
        retval = new ConnCompReduceAttributes(*this);
    // Other cases could go here too.

    return retval;
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::NewInstance
//
// Purpose:
//   NewInstance method for the ConnCompReduceAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

AttributeSubject *
ConnCompReduceAttributes::NewInstance(bool copy) const
{
    AttributeSubject *retval = 0;
    if(copy)
        retval = new ConnCompReduceAttributes(*this);
    else
        retval = new ConnCompReduceAttributes;

    return retval;
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::SelectAll
//
// Purpose:
//   Selects all attributes.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

void
ConnCompReduceAttributes::SelectAll()
{
    Select(ID_target, (void *)&target);
}

///////////////////////////////////////////////////////////////////////////////
// Persistence methods
///////////////////////////////////////////////////////////////////////////////

// ****************************************************************************
// Method: ConnCompReduceAttributes::CreateNode
//
// Purpose:
//   This method creates a DataNode representation of the object so it can be saved to a config file.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

bool
ConnCompReduceAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    ConnCompReduceAttributes defaultObject;
    bool addToParent = false;
    // Create a node for ConnCompReduceAttributes.
    DataNode *node = new DataNode("ConnCompReduceAttributes");

    if(completeSave || !FieldsEqual(ID_target, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("target", target));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::SetFromNode
//
// Purpose:
//   This method sets attributes in this object from values in a DataNode representation of the object.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

void
ConnCompReduceAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ConnCompReduceAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("target")) != 0)
        SetTarget(node->AsDouble());
}

///////////////////////////////////////////////////////////////////////////////
// Set property methods
///////////////////////////////////////////////////////////////////////////////

void
ConnCompReduceAttributes::SetTarget(double target_)
{
    target = target_;
    Select(ID_target, (void *)&target);
}

///////////////////////////////////////////////////////////////////////////////
// Get property methods
///////////////////////////////////////////////////////////////////////////////

double
ConnCompReduceAttributes::GetTarget() const
{
    return target;
}

///////////////////////////////////////////////////////////////////////////////
// Keyframing methods
///////////////////////////////////////////////////////////////////////////////

// ****************************************************************************
// Method: ConnCompReduceAttributes::GetFieldName
//
// Purpose:
//   This method returns the name of a field given its index.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

std::string
ConnCompReduceAttributes::GetFieldName(int index) const
{
    switch (index)
    {
    case ID_target: return "target";
    default:  return "invalid index";
    }
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::GetFieldType
//
// Purpose:
//   This method returns the type of a field given its index.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

AttributeGroup::FieldType
ConnCompReduceAttributes::GetFieldType(int index) const
{
    switch (index)
    {
    case ID_target: return FieldType_double;
    default:  return FieldType_unknown;
    }
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::GetFieldTypeName
//
// Purpose:
//   This method returns the name of a field type given its index.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

std::string
ConnCompReduceAttributes::GetFieldTypeName(int index) const
{
    switch (index)
    {
    case ID_target: return "double";
    default:  return "invalid index";
    }
}

// ****************************************************************************
// Method: ConnCompReduceAttributes::FieldsEqual
//
// Purpose:
//   This method compares two fields and return true if they are equal.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

bool
ConnCompReduceAttributes::FieldsEqual(int index_, const AttributeGroup *rhs) const
{
    const ConnCompReduceAttributes &obj = *((const ConnCompReduceAttributes*)rhs);
    bool retval = false;
    switch (index_)
    {
    case ID_target:
        {  // new scope
        retval = (target == obj.target);
        }
        break;
    default: retval = false;
    }

    return retval;
}

///////////////////////////////////////////////////////////////////////////////
// User-defined methods.
///////////////////////////////////////////////////////////////////////////////

